<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
             <!-- <a-form-item label="分配状态">
                <j-dict-select-tag placeholder="请选择分配状态" v-model="queryParam.allocationStatus" dict-code="allocation_status"></j-dict-select-tag>
              </a-form-item>-->
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            <a @click="handleToggleSearch" style="margin-left: 8px">
              {{ toggleSearchStatus ? '收起' : '展开' }}
              <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
            </a>
          </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleEdit" type="primary" icon="plus" >分配<a-icon type="update" /></a-button>

    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
      </a-table>
    </div>

    <rs-product-allocate-modal ref="modalForm" @ok="modalFormOk"></rs-product-allocate-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import RsProductAllocateModal from './modules/RsProductAllocateModal'
  import {postAction,getAction} from '@/api/manage';
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'RsOperateList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      RsProductAllocateModal

    },
    data () {
      return {
        description: '运营分配页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'产品名称',
            align:"center",
            dataIndex: 'productName'
          },
          {
            title:'产品链接',
            align:"center",
            dataIndex: 'productUrl'
          },
          {
            title:'货号',
            align:"center",
            dataIndex: 'productCode'
          },
          {
            title:'采购价',
            align:"center",
            dataIndex: 'purchasePrice'
          },
          {
            title:'零售价',
            align:"center",
            dataIndex: 'retailPrice'
          },
          {
            title:'销售方式',
            align:"center",
            dataIndex: 'ruleId_dictText'
          },
          {
            title:'素材链接',
            align:"center",
            dataIndex: 'materialLink'
          },
          {
            title:'分配状态',
            align:"center",
            dataIndex: 'allocationStatus_dictText'

          },
          {
            title:'设计师',
            align:"center",
            dataIndex: 'designer'

          }
        ],
        url: {
          list: "/shop/rsSelectProduct/list?column=allocationStatus&order=asc",
          changUrl: "/shop/rsSelectProduct/allocate",
          
        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      changData: function() {
        return `${window._CONFIG['domianURL']}/${this.url.changUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      handChange(){
        let id = this.selectedRowKeys;
        postAction(this.changData, id).then((res) => {
          if (res.success) {
            this.$message.warning(res.message)
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      }
    }
  }

</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>